import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:osg/controllers/http.dart';


class RankingSettings extends StatefulWidget {

  RankingSettings({super.key});

  @override
  State<RankingSettings> createState() => _SettingPageState();
}

class _SettingPageState extends State<RankingSettings> {


  RxBool falt = false.obs;
  RxMap myInfo={}.obs;

  getInfo(){
     Get.find<HTTPS>()
        .getData('/myRank', {}).then((res) {
      if (res != null) {
        myInfo.value = res;
        if(res['show_buy']=='1'){
            falt.value = true;
        }else{
            falt.value = false;
        }
      }
    });
  }

 @override
  void initState() {
    super.initState();
    WidgetsBinding.instance.addPostFrameCallback((_) {
      getInfo();
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
           appBar: AppBar(
            backgroundColor: Color(0xffffffff),
            title: Text('设置'),
            centerTitle: true
          ),
          body: Container(

            margin: EdgeInsets.symmetric(horizontal: 15),
            padding: EdgeInsets.symmetric(horizontal: 15,vertical: 10),
            decoration: BoxDecoration(
              borderRadius: BorderRadius.circular(10),
              color: Color(0XFFF8F9FD)
            ),
            child: Row(
              mainAxisAlignment:MainAxisAlignment.spaceBetween,
              children: [
                Text('名人堂买入对外可见'),
                GestureDetector(
                  onTap: (){
                      Get.find<HTTPS>()
                                .postData('/setRankShow', {
                                  "show_buy":falt.value?'0':'1'
                                }).then((res) {
                              if (res != null) {
                                  falt.value = ! falt.value;
                              }
                            });
                  },
                  child: 
                  Obx(()=>
                  Image.asset(falt.value?'static/web/skai.png':'static/web/sguan.png',width: 40,fit: BoxFit.fitWidth,),
                  
                  )
                )
                
              ],
            ),
          )

    );
  }
  

}
